	TITLE	'FORM FILE STRING FROM FCB'


	PAGEWIDTH 110

	CSEG

	PUBLIC	FCBFN,FFCBFN

FNLEN	EQU	8
FEXTL	EQU	3

;THIS SUBROUTINE FORMS A FILE NAME STRING FROM THE FIRST 12
;BYTES OF AN FCB.  ITS MAIN USE IS TO ISSUE AN ERROR MESSAGE
;ABOUT A FILE PROPERLY FORMATTED.  THE FILE STRING IS CONSTRUCTED
;IN THE USER BUFFER AND THE FIRST BYTE CONTAINS THE NUMBER OF
;BYTES IN THE FILE STRING.

;PROGRAMMED BY A. L. BENDER, M. D.
;NEUROLOGICAL SERVICES, INC.
;336 CENTER AVENUE
;WESTWOOD NJ 07675
;THIS IS IN PUBLIC DOMAIN AND MAY BE USED BY ALL BUT NEVER SOLD
;OR INCORPORATED IN SOFTWARE TO BE SOLD OR DISRIBUTED FOR PROFIT.
;

;
;CALL:
;	BX-->ADDRESS OF USER BUFFER TO STORE FILE NAME
;	DX-->ADDRESS OF USER'S FCB
;	CALL	FCBFN	;NEAR CALL
;OR	CALL	FFCBFN	;FAR CALL
;
;	IN EITHER CASE DS: MUST BE SET TO DATA SEGMENT OF BOTH
;	ON EXIT:
;	THE STRING IS IN THE USER'S BUFFER.
;	THE NUMBER OF BYTES IN THE STRING IS IN THE FIRST BYTE OF THE BUFFER
;	BX->UNDISTURBED
;	DX->UNDISTURBED
;	ALL OTHER REGISTERS UNCHANGED
;

FFCBFN:	CALL	FCBFN	;CALL NEAR PROCEDURE
	RETF		;RETURN FAR

FCBFN:	PUSH	ES
	PUSH	SI
	PUSH	DI
	PUSH	CX
	PUSH	AX
	PUSHF
	
	MOV	AX,DS
	MOV	ES,AX	;SET ES: TO DS:
	MOV	SI,0
	MOV	DI,DX
	MOV	BYTE PTR 0 [BX],0

	MOV	AL,[DI]
	TEST	AL,AL
	JZ	FN
	ADD	AL,'A'-1
	MOV	BYTE PTR 1 [BX],AL
	MOV	BYTE PTR 2 [BX],':'
	ADD	SI,2

FN:	MOV	CX,FNLEN
FN1:	MOV	AL, 1 [DI]	;FILE NAME
	CMP	AL,' '		;CHECK FOR BLANK
	JZ	FX		;FILE EXTENSION
	INC	SI
	MOV	BYTE PTR 0 [BX+SI],AL
	INC	DI
	LOOP	FN1
FX:	MOV	CX,FEXTL
	INC	SI
	MOV	BYTE PTR 0 [BX+SI],'.'
	MOV	DI,FNLEN	;GET TO EXTENSION
	ADD	DI,DX		;POINT TO IT

FX1:	MOV	AL, 1 [DI]	;FILE EXTENSION
	CMP	AL,' '
	JZ	DONE
	INC	SI
	INC	DI
	MOV	BYTE PTR 0 [BX+SI],AL
	LOOP	FX1
DONE:	MOV	CX,SI
	MOV	BYTE PTR 0 [BX],CL

	POPF
	POP	AX
	POP	CX
	POP	DI
	POP	SI
	POP	ES
	RET
	END
